<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class UserManageSite extends Model
{
    //
    use SoftDeletes;


    /*
     * 添加拥有者的管理关系，拥有者具备管理权限
     */
    public static function addOwner($user_id, $site_id)
    {
        $ums = UserManageSite::where('user_id', $user_id)->where('owner_id', $user_id)->where('site_id', $site_id)->first();
        if ($ums) {
            return true;
        }
        $ums = new UserManageSite();
        $ums->user_id = $user_id;
        $ums->owner_id = $user_id;
        $ums->site_id = $site_id;
        if ($ums->save()) {
            return true;
        } else {
            return false;
        }
    }

}
